package com.demo.enums;

import java.util.Objects;

/**
 * 病人性别枚举
 */
public enum PatientSexEnum {
    MAN(1, "男"),
    WOMEN(2, "女");

    private int value;
    private String desc;

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    PatientSexEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static PatientSexEnum getByValue(Integer value) {
        for (PatientSexEnum item : values()) {
            if (item.getValue() == value) {
                return item;
            }
        }
        return null;
    }


    public static PatientSexEnum getByDesc(String desc) {
        for (PatientSexEnum item : values()) {
            if (Objects.equals(desc, item.getDesc())) {
                return item;
            }
        }
        return null;
    }
}
